using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using System.Windows.Forms;
namespace ECCSystem.BizRule
{
	public static class ReadXML
	{
		#region "ReadXml"
		public static void ReadXml(Form objForm)
		{
			XmlDocument xd = new XmlDocument();
			string str = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
			xd.Load(str + "xmlSet.xml");
			XmlNode node = xd.SelectSingleNode("//" + objForm.Name);
			int nodesCount = node.ChildNodes.Count;
			for (int i = 0; i < nodesCount; i++)
			{

				string name = node.ChildNodes[i].LocalName;
				if ("height".Equals(name))
				{
					if (node.ChildNodes[i].InnerText == null)
					{

					}
					else
					{
						objForm.Height = Convert.ToInt32(node.ChildNodes[i].InnerText);
					}

				}

				if ("width".Equals(name))
				{
					if (node.ChildNodes[i].InnerText == null)
					{

					}
					else
					{
						objForm.Width = Convert.ToInt32(node.ChildNodes[i].InnerText);
					}
				}
			}

		}
		#endregion

		#region "SaveXml"
		public static void SaveXml(Form objForm)
		{
			XmlDocument xd = new XmlDocument();
			string str = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
			xd.Load(str + "xmlSet.xml");
			XmlNode node = xd.SelectSingleNode("//" + objForm.Name);
			int nodesCount = node.ChildNodes.Count;
			for (int i = 0; i < nodesCount; i++)
			{
				string name = node.ChildNodes[i].LocalName;
				if ("height".Equals(name))
				{
					node.ChildNodes[i].InnerText = objForm.Height.ToString();
				}

				if ("width".Equals(name))
				{
					node.ChildNodes[i].InnerText = objForm.Width.ToString();
				}
			}

			xd.Save(str + "xmlSet.xml");
		}
		#endregion
	}
}
